//
//  LLLabelNameSettingInputCell.m
//  LLBase
//
//  Created by LQ on 2022/11/21.
//

#import "WKLabelNameSettingInputCell.h"

@implementation WKLabelNameSettingInputModel

- (Class)cell {
    return WKLabelNameSettingInputCell.class;
}

@end

@interface WKLabelNameSettingInputCell ()

@property(nonatomic,strong) UITextField *textfield;
@property(nonatomic,strong) WKLabelNameSettingInputModel *labelNameSettingInputModel;

@end

@implementation WKLabelNameSettingInputCell

- (void)setupUI {
    [super setupUI];
    [self.contentView addSubview:self.textfield];
}
- (void)refresh:(WKLabelNameSettingInputModel *)model {
    [super refresh:model];
    self.labelNameSettingInputModel = model;
    self.textfield.placeholder = model.placeholder;
    self.textfield.text = model.value;
}

- (void)layoutSubviews {
    [super layoutSubviews];
    
    self.textfield.frame = self.contentView.bounds;
    self.textfield.lim_left = 15.0f;
}

- (UITextField *)textfield {
    if(!_textfield) {
        _textfield = [[UITextField alloc] init];
        [_textfield addTarget:self action:@selector(valueChange) forControlEvents:UIControlEventEditingChanged];
       
    }
    return _textfield;
}

-(void) valueChange {
    if(self.labelNameSettingInputModel.onChange) {
        self.labelNameSettingInputModel.onChange(self.textfield.text);
    }
}

@end
